# to attach leaflet dependencies we do an invisible map
# otherwise procedural leaflets wont render
# https://stackoverflow.com/questions/63534247/recommended-way-to-initialize-js-renderer-in-asis-r-markdown-chunk
leaflet::leaflet(width = 0, height = 0)
sli_performance%>%
select(-raw_comparison) %>%
DT::datatable()
for (i in 1:nrow(sli_performance)){
cat(sprintf("\n\n## %s\n\n", sli_performance$method[[i]]))
print(plot_sli_performance(sli_performance$raw_comparison[[i]],
title = sprintf("%s: Absolute performance", sli_performance$method[[i]]),
plot_type = "absolute"))
}
for (i in 1:nrow(sli_performance)){
cat(sprintf("\n\n## %s\n\n", sli_performance$method[[i]]))
map <- leaflet_sli_performance(sli_performance$raw_comparison[[i]], ons_shp, "diff_count")
cat(as.character(htmltools::tagList(map)))
}
for (i in 1:nrow(sli_performance)){
cat(sprintf("\n\n## %s\n\n", sli_performance$method[[i]]))
print(plot_sli_performance(sli_performance$raw_comparison[[i]],
title = sprintf("%s: Relative performance", sli_performance$method[[i]]),
plot_type = "proportional"))
print("\n\n")
print(sli_performance$raw_comparison[[i]]$diff_prop %>%
abs() %>%
hist(main = paste0("Histogram of mean abs. pct. error, ", sli_performance$method[[i]])))
print("\n\n")
print(sli_performance$raw_comparison[[i]]$diff_prop %>%
abs() %>%
summary())
}
[1] “”
$breaks [1] 0.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50
$counts [1] 85 7 3 5 3 2 1 0 1 1
$density [1] 15.7407407 1.2962963 0.5555556 0.9259259 0.5555556 0.3703704 [7] 0.1851852 0.0000000 0.1851852 0.1851852
$mids [1] 0.025 0.075 0.125 0.175 0.225 0.275 0.325 0.375 0.425 0.475
$xname [1] “.”
$equidist [1] TRUE
attr(,“class”) [1] “histogram” [1] “” Min. 1st Qu. Median Mean 3rd Qu. Max. 0.0000221 0.0022596 0.0090042 0.0472590 0.0351333 0.4603428
[1] “”
$breaks [1] 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
$counts [1] 83 11 5 4 2 0 1 1 0 1
$density [1] 7.68518519 1.01851852 0.46296296 0.37037037 0.18518519 0.00000000 [7] 0.09259259 0.09259259 0.00000000 0.09259259
$mids [1] 0.05 0.15 0.25 0.35 0.45 0.55 0.65 0.75 0.85 0.95
$xname [1] “.”
$equidist [1] TRUE
attr(,“class”) [1] “histogram” [1] “” Min. 1st Qu. Median Mean 3rd Qu. Max. 0.000000 0.002648 0.014955 0.083289 0.080902 1.000000
## Warning: Removed 1 rows containing missing values (geom_point).
[1] “”
$breaks [1] 0.0 0.2 0.4 0.6 0.8 1.0 1.2
$counts [1] 105 0 1 0 1 1
$density [1] 4.8611111 0.0000000 0.0462963 0.0000000 0.0462963 0.0462963
$mids [1] 0.1 0.3 0.5 0.7 0.9 1.1
$xname [1] “.”
$equidist [1] TRUE
attr(,“class”) [1] “histogram” [1] “” Min. 1st Qu. Median Mean 3rd Qu. Max. 0.000000 0.002261 0.010341 0.041462 0.024376 1.171429
[1] “”
$breaks [1] 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
$counts [1] 101 4 1 0 1 0 0 0 0 1
$density [1] 9.35185185 0.37037037 0.09259259 0.00000000 0.09259259 0.00000000 [7] 0.00000000 0.00000000 0.00000000 0.09259259
$mids [1] 0.05 0.15 0.25 0.35 0.45 0.55 0.65 0.75 0.85 0.95
$xname [1] “.”
$equidist [1] TRUE
attr(,“class”) [1] “histogram” [1] “” Min. 1st Qu. Median Mean 3rd Qu. Max. 0.000000 0.002312 0.010932 0.034512 0.025847 1.000000
[1] “”
$breaks [1] 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1
$counts [1] 101 4 0 0 1 0 0 0 1 0 1
$density [1] 9.35185185 0.37037037 0.00000000 0.00000000 0.09259259 0.00000000 [7] 0.00000000 0.00000000 0.09259259 0.00000000 0.09259259
$mids [1] 0.05 0.15 0.25 0.35 0.45 0.55 0.65 0.75 0.85 0.95 1.05
$xname [1] “.”
$equidist [1] TRUE
attr(,“class”) [1] “histogram” [1] “” Min. 1st Qu. Median Mean 3rd Qu. Max. 0.00000 0.00278 0.01222 0.04421 0.02568 1.05714
for (i in 1:nrow(sli_performance)){
cat(sprintf("\n\n## %s\n\n", sli_performance$method[[i]]))
map <- leaflet_sli_performance(sli_performance$raw_comparison[[i]], ons_shp, "diff_prop")
cat(as.character(htmltools::tagList(map)))
}
## Warning in pal(plot_var): Some values were outside the color scale and will be
## treated as NA
3
## [1] 3